//
//  LSYueBanInfoVC.m
//  LaSaCivilAffairsDepartment
//
//  Created by 姜晓延 on 2019/8/20.
//  Copyright © 2019 wpkj. All rights reserved.
//

#import "LSYueBanInfoVC.h"
#import "LSDownloadFilesViewController.h"
#import "LSLiuChengTuVC.h"
@interface LSYueBanInfoVC ()<UITextViewDelegate>

@property (nonatomic, strong) NSMutableArray *filesArray;

@property (nonatomic, strong) NSMutableDictionary *paraDict;

@property (nonatomic, strong) UIView *backgroundAlphaView;

@property (nonatomic, strong) UIScrollView *scrollView;

@property (nonatomic, strong) UIButton *saveBtn;

@property (nonatomic, strong) UIButton *faqiBtn;

@property (nonatomic, strong) UIView *fujianView;

@property (nonatomic, strong) NSMutableArray *upLoadFileArray;//已经上传的文件

//督办催办试图
@property (nonatomic, strong) UIView *dbcbView;
//点击督办催办按钮获取的数据
@property (nonatomic, strong) NSDictionary *dbcbDict;

@end

@implementation LSYueBanInfoVC
- (NSMutableArray *)upLoadFileArray{
    if (!_upLoadFileArray) {
        _upLoadFileArray = [NSMutableArray array];
    }
    return _upLoadFileArray;
}
- (NSMutableDictionary *)paraDict{
    if (!_paraDict) {
        _paraDict = [NSMutableDictionary dictionary];
    }
    return _paraDict;
}

- (NSMutableArray *)filesArray {
    if (!_filesArray) {
        _filesArray = [NSMutableArray array];
    }
    return _filesArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    if (self.type == 1) {
        self.title = @"查看";
        [self getNiWenData];
    }else if(self.type == 2){
        self.title = @"新增";
        [self addMakeView];
    }else{
        //编辑
        self.title = @"编辑";
        [self getBianJiData];
    }
    
    // Do any additional setup after loading the view.
}
#pragma mark 编辑
- (void)getBianJiData{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",YbManageUpdate,[UserInfoModel sharedInstance].token] param:@{@"id":[ValidateUtils validateNull:self.dict[@"id"]]} completionHandler:^(id responseObject, NSError *connectionError) {
        [hud hideAnimated:true];
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            
            if (status.integerValue == 200) {
                [self.paraDict addEntriesFromDictionary:[responseObject[@"data"]firstObject]];
                [self makeBianJiViewWith:[responseObject[@"data"]firstObject]];
            } else {
                [self makeBianJiViewWith:@{}];
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        } else {
           
                [self makeBianJiViewWith:@{}];
           
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}
- (void)makeBianJiViewWith:(NSDictionary*)dict{
    UIScrollView *scrollVIew = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-SafeAreaTopHeight)];
    [self.view addSubview:scrollVIew];
    self.scrollView = scrollVIew;
    NSArray *values = @[[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileNum"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileReceiveDate"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileTitle"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileCompany"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileCode"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileClassify"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileCount"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"securityClassification"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileRemark"]]]];
    NSArray *names = @[@"原文编号：",@"收文时间：",@"文件标题：",@"来文单位：",@"字号：",@"收文分类：",@"收文分数： ",@"密级：",@"备注："];
    CGFloat maxY = 0;
    for (NSInteger i = 0; i < names.count; i++) {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50)];
        view.backgroundColor = hexColor(ffffff);
        view.tag = 50000+i;
        [scrollVIew addSubview:view];
        
        UIImageView *hongdianImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 20, 10, 10)];
        hongdianImage.tag = 30000+i;
        hongdianImage.image = [UIImage imageNamed:@"xinhao"];
        //        hongdianImage.backgroundColor = [UIColor redColor];
        //        hongdianImage.clipsToBounds = YES;
        //        hongdianImage.layer.cornerRadius = 5;
        [view addSubview:hongdianImage];
        
        CGFloat maxX = CGRectGetMaxX(hongdianImage.frame);;
        if (i == 0 || i== 2 || i==3 || i == 4 || i==5 || i==6) {
            hongdianImage.hidden = NO;
        }else{
            
            hongdianImage.hidden = YES;
        }
        
        
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10+maxX, 10, 80, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [view addSubview:titlelabel];
        titlelabel.tag = 40000+i;
        titlelabel.text = names[i];
        
        
        if (i == 8) {
            UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(10, 10+CGRectGetMaxY(titlelabel.frame), ScreenWidth-10-10, 200)];
            textView.delegate = self;
            textView.text = values[i];
            textView.tag = 100+i;
            textView.font = [UIFont systemFontOfSize:15];
            view.frame = CGRectMake(0, maxY, ScreenWidth, 10+30+10+200+10);
            [view addSubview:textView];
            textView.clipsToBounds = YES;
            textView.layer.borderColor = hexColor(666666).CGColor;
            textView.layer.borderWidth = 1;
        }else{
            
            UITextView *textFiled = [[UITextView alloc]initWithFrame:CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-maxX, 30)];
            textFiled.textColor = hexColor(333333);
            textFiled.scrollEnabled = NO;
            textFiled.font = [UIFont systemFontOfSize:15];
            [view addSubview:textFiled];
            textFiled.delegate = self;
            textFiled.tag = 100+i;
//            textFiled.placeholder = [[NSString stringWithFormat:@"请输入%@",names[i]] stringByReplacingOccurrencesOfString:@"：" withString:@""];
            textFiled.text = values[i];
            if (i == 0 || i == 1) {
                textFiled.userInteractionEnabled = NO;
                if (i == 1) {
                    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                    
                    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[values[i] substringToIndex:10] integerValue]];
                    
                    textFiled.text = [dateFormatter stringFromDate:date];
                    self.paraDict[@"fileReceiveDate"] = textFiled.text;
                }
            }
            if (i == 7) {
                textFiled.textAlignment = NSTextAlignmentCenter;
                textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                textFiled.backgroundColor = hexColor(f0f0f0);
                textFiled.editable = NO;
                if ([values[i] isEqualToString:@"0"]) {
                    textFiled.text = @"公开";
                }else if ([values[i] isEqualToString:@"1"]){
                    textFiled.text = @"国内";
                }else if ([values[i] isEqualToString:@"2"]){
                    textFiled.text = @"内部";
                }else if ([values[i] isEqualToString:@"3"]){
                    textFiled.text = @"秘密";
                }else if ([values[i] isEqualToString:@"4"]){
                    textFiled.text = @"机密";
                }else if ([values[i] isEqualToString:@"5"]){
                    textFiled.text = @"绝密";
                }
                UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                zhankaiBtn.frame = CGRectMake(ScreenWidth-50, 5, 40, 40);
                [zhankaiBtn setImage:[UIImage imageNamed:@"xiala"] forState:UIControlStateNormal];
                zhankaiBtn.enabled = NO;
                [view addSubview:zhankaiBtn];
            }
            
            if (i == 5) {
                textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                textFiled.backgroundColor = hexColor(f0f0f0);
                textFiled.editable = NO;
                textFiled.textAlignment = NSTextAlignmentCenter;
                
                UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50+10, 15, 20, 20)];
                imageView.image = [UIImage imageNamed:@"xiala"];
                [view addSubview:imageView];
                
                UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                zhankaiBtn.frame = CGRectMake(10+80, 5, ScreenWidth-90, 40);
                [zhankaiBtn addTarget:self action:@selector(isopenchoose) forControlEvents:UIControlEventTouchUpInside];
                [view addSubview:zhankaiBtn];
                if ([values[i] isEqualToString:@"central"]) {
                    textFiled.text = @"中央文件";
                }else if ([values[i] isEqualToString:@"autonomousRegion"]){
                    textFiled.text = @"自治区文件";
                }else if ([values[i] isEqualToString:@"MuniGovernment"]){
                    textFiled.text = @"市委市政府文件";
                }else if ([values[i] isEqualToString:@"bureau"]){
                    textFiled.text = @"本局文件";
                }else if ([values[i] isEqualToString:@"MuniDepartments"]){
                    textFiled.text = @"市直相关部门文件";
                }
                
            }
            if(i == 6){
                textFiled.keyboardType =  UIKeyboardTypeNumberPad;
            }
            
            if (i > 7) {
                textFiled.editable = NO;
            }
            UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(textFiled.frame)+9, ScreenWidth, 1)];
            lineViwe.backgroundColor = hexColor(f0f0f0);
            lineViwe.tag = 20000+i;
            [view addSubview:lineViwe];
        }
       
        maxY = CGRectGetMaxY(view.frame);
    }
    
    //,@"附件:"
    
    NSArray *arr  = [NSArray arrayWithArray:dict[@"attachment"]];
    [self.upLoadFileArray addObjectsFromArray:arr];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50*(arr.count+1))];
    view.backgroundColor = hexColor(ffffff);
    [scrollVIew addSubview:view];
    self.fujianView = view;
    UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
    titlelabel.font = [UIFont systemFontOfSize:15];
    titlelabel.textColor = hexColor(333333);
    [view addSubview:titlelabel];
    titlelabel.text =@"附件：";
    UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    downBtn.frame = CGRectMake(ScreenWidth-50,5 , 40, 40);
    [downBtn setImage:[UIImage imageNamed:@"fujian"] forState:UIControlStateNormal];
    [downBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
    [view addSubview:downBtn];
    downBtn.tag = 2000;
    [downBtn addTarget:self action:@selector(addFiles) forControlEvents:UIControlEventTouchUpInside];
    
    if (arr.count > 0) {
        for (NSInteger i = 0; i < arr.count; i++) {
            NSDictionary *dict = arr[i];
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(titlelabel.frame)+10 + i*50, ScreenWidth-10-10-40-50, 30)];
            label.font = [UIFont systemFontOfSize:14];
            label.textColor = hexColor(333333);
            label.text = dict[@"fileName"];
            [view addSubview:label];
            UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            downBtn.frame = CGRectMake(ScreenWidth-50-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
            [downBtn setImage:[UIImage imageNamed:@"xiazai"] forState:UIControlStateNormal];
            [view addSubview:downBtn];
            downBtn.tag = 5000+i;
            [downBtn addTarget:self action:@selector(downFileStart:) forControlEvents:UIControlEventTouchUpInside];
            
            UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
            deleteBtn.frame = CGRectMake(ScreenWidth-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
            [deleteBtn setImage:[UIImage imageNamed:@"shanchu"] forState:UIControlStateNormal];
            [self.fujianView addSubview:deleteBtn];
            deleteBtn.tag = 4000+i;
            [deleteBtn addTarget:self action:@selector(delectFile:) forControlEvents:UIControlEventTouchUpInside];
            
            UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
            lineViwe.backgroundColor = hexColor(f0f0f0);
            [view addSubview:lineViwe];
        }
    }
    
    maxY = CGRectGetMaxY(view.frame);
    scrollVIew.contentSize = CGSizeMake(0, maxY+10);
    self.saveBtn  = [UIButton buttonWithType:UIButtonTypeCustom];
    self.saveBtn.backgroundColor = hexColor(FFBC01);
    [self.saveBtn setTitle:@"保存" forState:UIControlStateNormal];
    self.saveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.saveBtn.frame = CGRectMake(20, CGRectGetMaxY(self.fujianView.frame)+20, (ScreenWidth-60)/2.0, 40);
    [scrollVIew addSubview:self.saveBtn];
    
    self.saveBtn.clipsToBounds = YES;
    self.saveBtn.layer.cornerRadius = 5;
    
    self.faqiBtn  = [UIButton buttonWithType:UIButtonTypeCustom];
    self.faqiBtn.backgroundColor = hexColor(FFBC01);
    [self.faqiBtn setTitle:@"发起" forState:UIControlStateNormal];
    self.faqiBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.faqiBtn.frame = CGRectMake(CGRectGetMaxX(self.saveBtn.frame)+20, CGRectGetMaxY(self.fujianView.frame)+20, (ScreenWidth-60)/2.0, 40);
    [scrollVIew addSubview:self.faqiBtn];
    self.faqiBtn.clipsToBounds = YES;
    self.faqiBtn.layer.cornerRadius = 5;
    scrollVIew.contentSize = CGSizeMake(0, CGRectGetMaxY(self.faqiBtn.frame)+10);
    [self.saveBtn addTarget:self action:@selector(subData:) forControlEvents:UIControlEventTouchUpInside];
    [self.faqiBtn addTarget:self action:@selector(subData:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)textViewDidChange:(UITextView *)textView{
//    [textView flashScrollIndicators];   // 闪动滚动条
    if (textView.tag != 108) {
        static CGFloat maxHeight = 10000000.0f;
             CGRect frame = textView.frame;
             CGSize constraintSize = CGSizeMake(frame.size.width, MAXFLOAT);
             CGSize size = [textView sizeThatFits:constraintSize];
             if (size.height >= maxHeight)
             {
                 size.height = maxHeight;
                 textView.scrollEnabled = YES;    // 允许滚动
             }
             else
             {
                 textView.scrollEnabled = NO;    // 不允许滚动，当textview的大小足以容纳它的text的时候，需要设置scrollEnabed为NO，否则会出现光标乱滚动的情况
             }
           if (size.height > 30) {
               UIView *view = [self.view viewWithTag:textView.tag%100+50000];
               UIView *lineView = [self.view viewWithTag:textView.tag%100+20000];
               CGRect viewframe = view.frame;
               viewframe.size.height = viewframe.size.height+(size.height-frame.size.height);
               view.frame = viewframe;
               
               UIImageView *redImage = [self.view viewWithTag:textView.tag%100+30000];
               CGRect redFrame = redImage.frame;
               redFrame.origin.y = (view.frame.size.height-redFrame.size.height)/2.0;
               redImage.frame = redFrame;
               
               UILabel *titlelabel = [self.view viewWithTag:textView.tag%100+40000];
               CGRect titleFrame = titlelabel.frame;
               titleFrame.origin.y = (view.frame.size.height-titleFrame.size.height)/2.0;
               titlelabel.frame = titleFrame;

               textView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, size.height);
               lineView.frame = CGRectMake(0, CGRectGetMaxY(textView.frame)+9, ScreenWidth, 1);
               if (textView.tag == 102 || textView.tag == 103 || textView.tag == 104) {
                    [self changeViewPositionWithFromTag:textView.tag];
               }
           }
    }
}
#pragma mark - 根据文字刷新界面
- (void)changeViewPositionWithFromTag:(NSInteger)tag{
    CGFloat maxY = 0;
     for (NSInteger i = tag+1; i<109; i++) {
             UIView *topview = [self.view viewWithTag:(i-1)%100+50000];
              UIView *bottomView = [self.view viewWithTag:i%100+50000];
              CGRect viewframe = bottomView.frame;
              viewframe.origin.y = CGRectGetMaxY(topview.frame);
              bottomView.frame = viewframe;
                  maxY = CGRectGetMaxY(bottomView.frame);
    }
   
    CGRect fujianFrame = self.fujianView.frame;
    fujianFrame.origin.y = maxY;
    self.fujianView.frame = fujianFrame;
    self.saveBtn.frame = CGRectMake(20, CGRectGetMaxY(self.fujianView.frame)+20, (ScreenWidth-60)/2.0, 40);
    self.faqiBtn.frame = CGRectMake(CGRectGetMaxX(self.saveBtn.frame)+20, CGRectGetMaxY(self.fujianView.frame)+20, (ScreenWidth-60)/2.0, 40);
    self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(self.faqiBtn.frame)+20);
                                    
}
- (void)textViewDidEndEditing:(UITextView *)textView{
    if (textView.tag == 108) {
        self.paraDict[@"fileRemark"] = textView.text;
    }
    switch (textView.tag) {
           case 102:
           {
               self.paraDict[@"fileTitle"] = textView.text;
           }
               break;
           case 103:
           {
               self.paraDict[@"fileCompany"] = textView.text;
           }
               break;
           case 104:
           {
               self.paraDict[@"fileCode"] = textView.text;
           }
               break;
               //        case 105:
               //        {
               //             self.paraDict[@"notOpenReason"] = textField.text;
               //        }
               //            break;
           case 106:
           {
               self.paraDict[@"fileCount"] = textView.text;
           }
               break;
         
           default:
               break;
       }
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if (textView.tag == 108) {
           if (range.location >499 || [NSString stringWithFormat:@"%@%@",textView.text,text].length>500) {
               NSString *string = [NSString stringWithFormat:@"%@%@",textView.text,text];
               textView.text = [string substringToIndex:500];
               return NO;
           }
       }
    if (textView.tag == 102) {
           if (range.location > 29 || [NSString stringWithFormat:@"%@%@",textView.text,text].length>30) {
                NSString *string = [NSString stringWithFormat:@"%@%@",textView.text,text];
                             textView.text = [string substringToIndex:30];
                             return NO;
           } else {
               if (([ValidateUtils isInputRuleNotBlank:text] && ![ValidateUtils hasSpecialString:text]) || [text isEqualToString:@""]) {//当输入符合规则和退格键时允许改变输入框
                   return YES;
               } else {
                   return NO;
               }
           }
       }
       if (textView.tag == 103) {
           if (range.location > 29|| [NSString stringWithFormat:@"%@%@",textView.text,text].length>30) {
                 NSString *string = [NSString stringWithFormat:@"%@%@",textView.text,text];
                                         textView.text = [string substringToIndex:30];
                                         return NO;
           } else {
               if (([ValidateUtils isInputRuleNotBlank:text] && ![ValidateUtils hasSpecialString:text]) || [text isEqualToString:@""]) {//当输入符合规则和退格键时允许改变输入框
                   return YES;
               } else {
                   return NO;
               }
           }
       }
       if (textView.tag == 104) {
           if (range.location > 15||[NSString stringWithFormat:@"%@%@",textView.text,text].length>15) {
                 NSString *string = [NSString stringWithFormat:@"%@%@",textView.text,text];
                                         textView.text = [string substringToIndex:15];
                                         return NO;
           }
       }
       if (textView.tag == 106) {
           if ([ValidateUtils validateContainNumberAndLetter:text]!=1) {
               return NO;
           }
           if (range.location > 2) {
               return NO;
           }
       }
       return YES;
       return YES;
}
#pragma mark 新增
- (void)addMakeView{
    UIScrollView *scrollVIew = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-SafeAreaTopHeight)];
    [self.view addSubview:scrollVIew];
    self.scrollView = scrollVIew;
    NSArray *names = @[@"原文编号：",@"收文时间：",@"文件标题：",@"来文单位：",@"字号：",@"收文分类：",@"收文份数： ",@"密级：",@"备注："];
    CGFloat maxY = 0;
    for (NSInteger i = 0; i < names.count; i++) {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50)];
        view.backgroundColor = hexColor(ffffff);
        view.tag = 50000+i;
        [scrollVIew addSubview:view];
        
        UIImageView *hongdianImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 20, 10, 10)];
        hongdianImage.tag = 30000+i;
        hongdianImage.image = [UIImage imageNamed:@"xinhao"];
        [view addSubview:hongdianImage];
        
        CGFloat maxX = CGRectGetMaxX(hongdianImage.frame);;
        if (i == 0 || i== 2 || i==3 || i == 4 || i==5 || i==6) {
            hongdianImage.hidden = NO;
        }else{
            
            hongdianImage.hidden = YES;
        }
        
        
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10+maxX, 10, 80, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [view addSubview:titlelabel];
        titlelabel.tag = 40000+i;
        titlelabel.text = names[i];
        
        
        if (i == 8) {
            UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(10, 10+CGRectGetMaxY(titlelabel.frame), ScreenWidth-10-10, 200)];
            textView.tag = 100+i;
             textView.delegate = self;
            textView.font = [UIFont systemFontOfSize:15];
            view.frame = CGRectMake(0, maxY, ScreenWidth, 10+30+10+200+10);
            [view addSubview:textView];
            textView.clipsToBounds = YES;
            textView.layer.borderColor = hexColor(666666).CGColor;
            textView.layer.borderWidth = 1;
        }else{
            
            UITextView *textFiled = [[UITextView alloc]initWithFrame:CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-maxX, 30)];
            textFiled.textColor = hexColor(333333);
            textFiled.font = [UIFont systemFontOfSize:15];
            [view addSubview:textFiled];
            textFiled.delegate = self;
            textFiled.scrollEnabled = NO;
            textFiled.tag = 100+i;
//            textFiled.placeholder = [[NSString stringWithFormat:@"请输入%@",names[i]] stringByReplacingOccurrencesOfString:@"：" withString:@""];
            if (i == 0 || i == 1) {
                textFiled.userInteractionEnabled = NO;
               
                if (i == 1) {
                    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                    NSDate *date = [NSDate date];
                   textFiled.text = [dateFormatter stringFromDate:date];
                    self.paraDict[@"fileReceiveDate"] = textFiled.text;
                }else{
                    NSDateFormatter *df2 = [[NSDateFormatter alloc] init];//格式化
                    [df2 setDateFormat:@"yyyyMMddHHmmssSSS"];
                    NSDate *date = [NSDate date];
                    textFiled.text = [df2 stringFromDate:date];
                    self.paraDict[@"fileNum"] = textFiled.text;
                }
            }
            if (i == 7) {
                textFiled.textAlignment = NSTextAlignmentCenter;
                textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                textFiled.backgroundColor = hexColor(f0f0f0);
                textFiled.editable = NO;
                textFiled.text = @"公开";
                self.paraDict[@"securityClassification"] = @"0";
                UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                zhankaiBtn.frame = CGRectMake(ScreenWidth-50, 5, 40, 40);
                [zhankaiBtn setImage:[UIImage imageNamed:@"xiala"] forState:UIControlStateNormal];
                zhankaiBtn.enabled = NO;
                [view addSubview:zhankaiBtn];
            }
            
            if (i == 5) {
                textFiled.frame = CGRectMake(10+80+maxX, 10, ScreenWidth-10-90-40-maxX, 30);
                textFiled.backgroundColor = hexColor(f0f0f0);
                textFiled.editable = NO;
                textFiled.textAlignment = NSTextAlignmentCenter;
                
                UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth-50+10, 15, 20, 20)];
                imageView.image = [UIImage imageNamed:@"xiala"];
                [view addSubview:imageView];
                
                UIButton *zhankaiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                zhankaiBtn.frame = CGRectMake(10+80, 5, ScreenWidth-90, 40);
                [zhankaiBtn addTarget:self action:@selector(isopenchoose) forControlEvents:UIControlEventTouchUpInside];
                [view addSubview:zhankaiBtn];
                
                textFiled.text = @"中央文件";
                self.paraDict[@"fileClassify"] = @"central";

                
            }
            if(i == 6){
                textFiled.keyboardType =  UIKeyboardTypeNumberPad;
            }
            
            if (i > 7) {
                textFiled.editable = NO;
            }
            UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(textFiled.frame)+9, ScreenWidth, 1)];
            lineViwe.backgroundColor = hexColor(f0f0f0);
            lineViwe.tag = 20000+i;
            [view addSubview:lineViwe];
        }
        
        maxY = CGRectGetMaxY(view.frame);
    }
    
  
    
    //,@"附件:"
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50*(self.filesArray.count+1))];
    view.backgroundColor = hexColor(ffffff);
    [scrollVIew addSubview:view];
    self.fujianView = view;
    UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
    titlelabel.font = [UIFont systemFontOfSize:15];
    titlelabel.textColor = hexColor(333333);
    [view addSubview:titlelabel];
    titlelabel.text =@"附件：";
    UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    downBtn.frame = CGRectMake(ScreenWidth-50,5 , 40, 40);
    [downBtn setImage:[UIImage imageNamed:@"fujian"] forState:UIControlStateNormal];
    [downBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
    [view addSubview:downBtn];
    downBtn.tag = 2000;
    [downBtn addTarget:self action:@selector(addFiles) forControlEvents:UIControlEventTouchUpInside];
    maxY = CGRectGetMaxY(view.frame);
    scrollVIew.contentSize = CGSizeMake(0, maxY+10);
    
    self.saveBtn  = [UIButton buttonWithType:UIButtonTypeCustom];
    self.saveBtn.backgroundColor = hexColor(FFBC01);
    [self.saveBtn setTitle:@"保存" forState:UIControlStateNormal];
    self.saveBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.saveBtn.frame = CGRectMake(20, CGRectGetMaxY(self.fujianView.frame)+20, (ScreenWidth-60)/2.0, 40);
    [scrollVIew addSubview:self.saveBtn];
    
    self.saveBtn.clipsToBounds = YES;
    self.saveBtn.layer.cornerRadius = 5;
    
    self.faqiBtn  = [UIButton buttonWithType:UIButtonTypeCustom];
    self.faqiBtn.backgroundColor = hexColor(FFBC01);
    [self.faqiBtn setTitle:@"发起" forState:UIControlStateNormal];
    self.faqiBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.faqiBtn.frame = CGRectMake(CGRectGetMaxX(self.saveBtn.frame)+20, CGRectGetMaxY(self.fujianView.frame)+20, (ScreenWidth-60)/2.0, 40);
    [scrollVIew addSubview:self.faqiBtn];
    self.faqiBtn.clipsToBounds = YES;
    self.faqiBtn.layer.cornerRadius = 5;
    scrollVIew.contentSize = CGSizeMake(0, CGRectGetMaxY(self.faqiBtn.frame)+10);
    [self.saveBtn addTarget:self action:@selector(subData:) forControlEvents:UIControlEventTouchUpInside];
    [self.faqiBtn addTarget:self action:@selector(subData:) forControlEvents:UIControlEventTouchUpInside];
}
-(NSData*)readFileData:(NSString *)path{
    NSFileHandle *handle = [NSFileHandle fileHandleForReadingAtPath:path];
    NSData *fileData = [handle readDataToEndOfFile];
    [handle closeFile];
    return fileData;
}
- (void)subData:(UIButton*)button{
    [self.view endEditing:YES];
    if ([ValidateUtils validateNull:self.paraDict[@"fileTitle"]].length <= 1) {
        [MBProgressHUD showWarnMessage:@"文件标题请填写2到30位任意字符"];
        return;
    }
    if ([ValidateUtils validateNull:self.paraDict[@"fileCompany"]].length <= 1) {
        [MBProgressHUD showWarnMessage:@"来文单位请填写2到30位任意字符"];
        return;
    }
    if ([ValidateUtils validateNull:self.paraDict[@"fileCode"]].length <= 1) {
        [MBProgressHUD showWarnMessage:@"字号请填写2到16位任意字符"];
        return;
    }
    
    if ([ValidateUtils validateNull:self.paraDict[@"fileCount"]].length == 0 ||[[ValidateUtils validateNull:self.paraDict[@"fileCount"]] integerValue ]== 0) {
        [MBProgressHUD showWarnMessage:@"份数请填写1到3位任意数字"];
        return;
    }
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    if (self.filesArray.count>0) {
        NSMutableArray *nameArr = [NSMutableArray array];
        NSMutableArray *fileNameArr = [NSMutableArray array];
        NSMutableArray *dataArray = [NSMutableArray array];
        for (NSInteger i = 0; i < self.filesArray.count; i++) {
            NSString *filePath = self.filesArray[i];
            NSData *data = [self readFileData:filePath];
            [nameArr addObject:[NSString stringWithFormat:@"File%ld",i+1]];
            [fileNameArr addObject:[filePath componentsSeparatedByString:@"/"].lastObject];
            [dataArray addObject:data];
        }
        [NetworkUtils uploadFileNoHandleWithURL:[NSString stringWithFormat:@"%@&token=%@",yzFileDeal,[UserInfoModel sharedInstance].token] param:@{}.mutableCopy data:dataArray name:nameArr filename:fileNameArr completionHandler:^(id responseObject, NSError *connectionError) {
            hud.hidden = YES;
            if (!connectionError) {
                NSNumber *status = [responseObject objectForKey:@"status"];
                
                if (status.integerValue == 200) {
                    NSArray *arr = [NSArray arrayWithArray:responseObject[@"attachment"]];
                    NSMutableString *filePath = [NSMutableString string];
                    if (self.upLoadFileArray.count>0) {
                        for (NSInteger i = 0; i< self.upLoadFileArray.count; i++) {
                            NSDictionary *fileDict = self.upLoadFileArray[i];
                            [filePath appendFormat:@"%@,",fileDict[@"filePath"]];
                        }
                    }
                    for (NSInteger i = 0; i< arr.count; i++) {
                        NSDictionary *fileDict = arr[i];
                        if (i != arr.count-1) {
                            [filePath appendFormat:@"%@,",fileDict[@"filePath"]];
                        }else{
                            [filePath appendFormat:@"%@",fileDict[@"filePath"]];
                        }
                        
                    }
                    self.paraDict[@"attachment"] = filePath;
                    [self uploadData:button];
                    
                } else {
                    [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                    [self uploadData:button];
                }
            } else {
                [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
                [self uploadData:button];
            }
            
        }];
        
    }else{
        NSMutableString *filePath = [NSMutableString string];
        
        if (self.upLoadFileArray.count>0) {
            for (NSInteger i = 0; i< self.upLoadFileArray.count; i++) {
                NSDictionary *fileDict = self.upLoadFileArray[i];
                if (i != self.upLoadFileArray.count-1) {
                    [filePath appendFormat:@"%@,",fileDict[@"filePath"]];
                }else{
                    [filePath appendFormat:@"%@",fileDict[@"filePath"]];
                }
            }
        }
        self.paraDict[@"attachment"] = filePath;
        [self uploadData:button];
    }
    
    
}
- (void)uploadData:(UIButton*)button{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    if ([button isEqual:self.saveBtn]) {
        if (self.type == 2) {
            
            [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",YbManageAdd,[UserInfoModel sharedInstance].token] param:self.paraDict completionHandler:^(id responseObject, NSError *connectionError) {
                hud.hidden = YES;
                if (!connectionError) {
                    NSNumber *status = [responseObject objectForKey:@"status"];
                    
                    if (status.integerValue == 200) {
                        [MBProgressHUD showSuccessMessage:@"保存成功！"];
                        [self.navigationController popViewControllerAnimated:YES];
                    } else {
                        [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                    }
                } else {
                    [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
                }
            }];
        }else{
            NSDictionary *param = @{
            @"id":self.paraDict[@"id"],
            @"fileNum":self.paraDict[@"fileNum"],
            @"fileReceiveDate":self.paraDict[@"fileReceiveDate"],
            @"fileTitle":self.paraDict[@"fileTitle"],
            @"fileCompany":self.paraDict[@"fileCompany"],
            @"fileCode":self.paraDict[@"fileCode"],
            @"fileClassify":[ValidateUtils validateNull:self.paraDict[@"fileClassify"]],
            @"fileCount":self.paraDict[@"fileCount"],
            @"securityClassification":self.paraDict[@"securityClassification"],
            @"attachment":[ValidateUtils validateNull:self.paraDict[@"attachment"]],
            @"fileRemark":[ValidateUtils validateNull:self.paraDict[@"fileRemark"]],@"token":[UserInfoModel sharedInstance].token};
            NSLog(@"%@",param);
            [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@",YbManageEdit] param:param completionHandler:^(id responseObject, NSError *connectionError) {
                hud.hidden = YES;
                if (!connectionError) {
                    NSNumber *status = [responseObject objectForKey:@"status"];
                    if (status.integerValue == 200) {
                        [MBProgressHUD showSuccessMessage:responseObject[@"message"]];
                        [self.navigationController popViewControllerAnimated:YES];
                    } else {
                        [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                    }
                } else {
                    [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
                }
            }];
        }
    }else{
        NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
          [paraDict addEntriesFromDictionary:self.paraDict];
        if (self.type != 2) {
            if ([ValidateUtils validateNull:self.paraDict[@"createDate"]].length > 10) {
                NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
                
                NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[[ValidateUtils validateNull:self.paraDict[@"createDate"]] substringToIndex:10] integerValue]];
                
                self.paraDict[@"createDate"] = [dateFormatter stringFromDate:date];
            }
          
        }
      
        [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",YbManageBegin,[UserInfoModel sharedInstance].token] param:self.paraDict completionHandler:^(id responseObject, NSError *connectionError) {
            hud.hidden = YES;
             NSLog(@"阅办发起：%@",responseObject);
            if (!connectionError) {
                NSNumber *status = [responseObject objectForKey:@"status"];
                if (status.integerValue == 200) {
                    [MBProgressHUD showSuccessMessage:responseObject[@"message"]];
                    if (self.HavedAddNewData) {
                        self.HavedAddNewData();
                    }
                    [self.navigationController popViewControllerAnimated:YES];
                } else {
                    [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                }
            } else {
                [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
            }
        }];
    }
}
- (void)isopenchoose{
    //    [self.backgroundAlphaView removeFromSuperview];
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self.backgroundAlphaView];
     NSArray *names = @[@"中央文件",@"自治区文件",@"市委市政府文件",@"本局文件",@"市直相关部门文件"];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(20, 250+SafeAreaTopHeight, ScreenWidth-40, names.count*51)];
    view.backgroundColor = hexColor(ffffff);
    [self.backgroundAlphaView addSubview:view];
   
    for (NSInteger i = 0; i < names.count; i++) {
        UIButton *yesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        yesBtn.frame = CGRectMake(0, i*51, ScreenWidth-40, 50);
        [yesBtn setTitle:names[i] forState:UIControlStateNormal];
        [yesBtn setTitleColor:hexColor(333333) forState:UIControlStateNormal];
        [view addSubview:yesBtn];
        yesBtn.tag = 1000+i;
        [yesBtn addTarget:self action:@selector(yes:) forControlEvents:UIControlEventTouchUpInside];
        UIView *lineview = [[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth-40, 1)];
        lineview.backgroundColor = hexColor(f0f0f0);
        [view addSubview:lineview];
    }
   

}
- (void)yes:(UIButton*)button{
    UITextField *textFiled = [self.view viewWithTag:105];
  
    if (button.tag == 1000) {
        textFiled.text = @"中央文件";
        self.paraDict[@"fileClassify"] = @"central";
    }else if (button.tag == 1001){
        textFiled.text = @"自治区文件";
        self.paraDict[@"fileClassify"] = @"autonomousRegion";
    }else if (button.tag == 1002){
        textFiled.text = @"市委市政府文件";
        self.paraDict[@"fileClassify"] = @"MuniGovernment";
    }else if (button.tag == 1003){
        textFiled.text = @"本局文件";
        self.paraDict[@"fileClassify"] = @"bureau";
    }else if (button.tag == 1004){
        textFiled.text = @"市直相关部门文件";
        self.paraDict[@"fileClassify"] = @"MuniDepartments";
    }
    [self.backgroundAlphaView removeFromSuperview];
}

- (UIView *)backgroundAlphaView {
    if (!_backgroundAlphaView) {
        _backgroundAlphaView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
        _backgroundAlphaView.backgroundColor = hexColorAlpha(000000, 0.5);
        _backgroundAlphaView.userInteractionEnabled = true;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundAlphaViewTapped)];
        [_backgroundAlphaView addGestureRecognizer:tap];
    }
    return _backgroundAlphaView;
}

- (void)backgroundAlphaViewTapped {
    [self.backgroundAlphaView removeFromSuperview];
    
}
- (void)addFiles{
    LSDownloadFilesViewController *lvc = [[LSDownloadFilesViewController alloc] initWithEditableTableViewWithSelectedFilesArray:self.filesArray andDidSelectFilesBlock:^(NSArray * _Nonnull selectedFilesArray) {
        if (selectedFilesArray.count > 0) {
            [self.filesArray removeAllObjects];
            [self.filesArray addObjectsFromArray: selectedFilesArray];
            NSLog(@"selectedFilesArray---%@",selectedFilesArray);
            [self changeFuJIanUI];
        }
    }];
    [self.navigationController pushViewController:lvc animated:YES];
}
- (void)changeFuJIanUI{
    CGRect frame = self.fujianView.frame;
    
    if (self.type == 2) {
        frame.size.height = 50*(self.filesArray.count+1);
        self.fujianView.frame = frame;
        NSArray *arr = self.fujianView.subviews;
        for (UIView *view in arr) {
            [view removeFromSuperview];
        }
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [self.fujianView addSubview:titlelabel];
        titlelabel.text =@"附件：";
        UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        downBtn.frame = CGRectMake(ScreenWidth-50,5 , 40, 40);
        [downBtn setImage:[UIImage imageNamed:@"fujian"] forState:UIControlStateNormal];
        [downBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        [self.fujianView addSubview:downBtn];
        downBtn.tag = 2000;
        [downBtn addTarget:self action:@selector(addFiles) forControlEvents:UIControlEventTouchUpInside];
        if (self.filesArray.count > 0) {
            for (NSInteger i = 0; i < self.filesArray.count; i++) {
                NSString *filename = self.filesArray[i];
                UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(titlelabel.frame)+10 + i*50, ScreenWidth-10-10-40, 30)];
                label.font = [UIFont systemFontOfSize:14];
                label.textColor = hexColor(333333);
                NSArray *fileNames = [filename componentsSeparatedByString:@"/"];
                label.text = fileNames.lastObject;
                [self.fujianView addSubview:label];
                UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                downBtn.frame = CGRectMake(ScreenWidth-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
                [downBtn setImage:[UIImage imageNamed:@"shanchu"] forState:UIControlStateNormal];
                [self.fujianView addSubview:downBtn];
                downBtn.tag = 4000+i;
                [downBtn addTarget:self action:@selector(delectFile:) forControlEvents:UIControlEventTouchUpInside];
                UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
                lineViwe.backgroundColor = hexColor(f0f0f0);
                [self.fujianView addSubview:lineViwe];
            }
        }
        CGRect saveFrame = self.saveBtn.frame;
        saveFrame.origin.y = CGRectGetMaxY(self.fujianView.frame)+20;
        self.saveBtn.frame = saveFrame;
        CGRect faqiFrame = self.faqiBtn.frame;
        faqiFrame.origin.y = CGRectGetMaxY(self.fujianView.frame)+20;
        self.faqiBtn.frame = faqiFrame;
        self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(self.fujianView.frame)+10+20+30);
        
        
    }else{
        frame.size.height = 50*(self.filesArray.count+1+self.upLoadFileArray.count);
        self.fujianView.frame = frame;
        NSArray *arr = self.fujianView.subviews;
        for (UIView *view in arr) {
            [view removeFromSuperview];
        }
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [self.fujianView addSubview:titlelabel];
        titlelabel.text =@"附件：";
        UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        downBtn.frame = CGRectMake(ScreenWidth-50,5 , 40, 40);
        [downBtn setImage:[UIImage imageNamed:@"fujian"] forState:UIControlStateNormal];
        [downBtn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        [self.fujianView addSubview:downBtn];
        downBtn.tag = 2000;
        [downBtn addTarget:self action:@selector(addFiles) forControlEvents:UIControlEventTouchUpInside];
        CGFloat maxY = CGRectGetMaxY(titlelabel.frame);
        if (self.upLoadFileArray.count > 0) {
            for (NSInteger i = 0; i < self.upLoadFileArray.count; i++) {
                NSString *filename = self.upLoadFileArray[i][@"fileName"];
                UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, maxY+10 + i*50, ScreenWidth-10-10-40, 30)];
                label.font = [UIFont systemFontOfSize:14];
                label.textColor = hexColor(333333);
                
                label.text = filename;
                [self.fujianView addSubview:label];
                UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                downBtn.frame = CGRectMake(ScreenWidth-50-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
                [downBtn setImage:[UIImage imageNamed:@"xiazai"] forState:UIControlStateNormal];
                [self.fujianView addSubview:downBtn];
                downBtn.tag = 5000+i;
                [downBtn addTarget:self action:@selector(downFileStart:) forControlEvents:UIControlEventTouchUpInside];
                
                UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                deleteBtn.frame = CGRectMake(ScreenWidth-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
                [deleteBtn setImage:[UIImage imageNamed:@"shanchu"] forState:UIControlStateNormal];
                [self.fujianView addSubview:deleteBtn];
                deleteBtn.tag = 4000+i;
                [deleteBtn addTarget:self action:@selector(delectFile:) forControlEvents:UIControlEventTouchUpInside];
                UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
                lineViwe.backgroundColor = hexColor(f0f0f0);
                [self.fujianView addSubview:lineViwe];
                maxY = CGRectGetMaxY(lineViwe.frame);
            }
        }
        
        if (self.filesArray.count > 0) {
            for (NSInteger i = 0; i < self.filesArray.count; i++) {
                NSString *filename = self.filesArray[i];
                UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, maxY+10 + i*50, ScreenWidth-10-10-40, 30)];
                label.font = [UIFont systemFontOfSize:14];
                label.textColor = hexColor(333333);
                NSArray *fileNames = [filename componentsSeparatedByString:@"/"];
                label.text = fileNames.lastObject;
                [self.fujianView addSubview:label];
                UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                downBtn.frame = CGRectMake(ScreenWidth-50,maxY+5 + i*50 , 40, 40);
                [downBtn setImage:[UIImage imageNamed:@"shanchu"] forState:UIControlStateNormal];
                [self.fujianView addSubview:downBtn];
                downBtn.tag = 6000+i;
                [downBtn addTarget:self action:@selector(delectFile:) forControlEvents:UIControlEventTouchUpInside];
                UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
                lineViwe.backgroundColor = hexColor(f0f0f0);
                [self.fujianView addSubview:lineViwe];
            }
        }
        CGRect saveFrame = self.saveBtn.frame;
        saveFrame.origin.y = CGRectGetMaxY(self.fujianView.frame)+20;
        self.saveBtn.frame = saveFrame;
        CGRect faqiFrame = self.faqiBtn.frame;
        faqiFrame.origin.y = CGRectGetMaxY(self.fujianView.frame)+20;
        self.faqiBtn.frame = faqiFrame;
        self.scrollView.contentSize = CGSizeMake(0, CGRectGetMaxY(self.fujianView.frame)+10+20+30);
    }
    
}
//新增删除文件
- (void)delectFile:(UIButton*)button{
    if (self.type == 2) {
        [self.filesArray removeObjectAtIndex:button.tag-4000];
        [self changeFuJIanUI];
    }else{
        if (button.tag >= 6000) {
            [self.filesArray removeObjectAtIndex:button.tag-6000];
            [self changeFuJIanUI];
        }else{
            
            MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
            NSDictionary *para = @{@"filePath":self.upLoadFileArray[button.tag-4000][@"filePath2"]};
            [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",yzFileDeletel,[UserInfoModel sharedInstance].token] param:para completionHandler:^(id responseObject, NSError *connectionError) {
                hud.hidden = YES;
                if (!connectionError) {
                    NSNumber *status = [responseObject objectForKey:@"status"];
                    
                    if (status.integerValue == 200) {
                        [self.upLoadFileArray removeObjectAtIndex:button.tag - 4000];
                        [self changeFuJIanUI];
                    } else {
                        
                        [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
                    }
                } else {
                    
                    [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
                }
            }];
        }
    }
    
}
#pragma  mark 查看
- (void)getNiWenData{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",YbManageDetail,[UserInfoModel sharedInstance].token] param:@{@"id":[ValidateUtils validateNull:self.dict[@"id"]]} completionHandler:^(id responseObject, NSError *connectionError) {
        [hud hideAnimated:true];
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            
            if (status.integerValue == 200) {
                [self.paraDict addEntriesFromDictionary:[responseObject[@"data"]firstObject]];
                [self makeViewWithDict:[responseObject[@"data"]firstObject]];
            } else {
               [self makeViewWithDict:@{}];
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        } else {
            [self makeViewWithDict:@{}];
           
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}
- (void)makeViewWithDict:(NSDictionary*)dict{
    if (dict.count > 0) {
        UIScrollView *scrollVIew = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-SafeAreaTopHeight)];
        [self.view addSubview:scrollVIew];
        NSArray *values = @[[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileNum"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileReceiveDate"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileTitle"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileCompany"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileCode"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileClassify"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileCount"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"securityClassification"]]],[NSString stringWithFormat:@"%@",[ValidateUtils validateNull:dict[@"fileRemark"]]]];
        NSArray *names = @[@"原文编号：",@"收文时间：",@"文件标题：",@"来文单位：",@"字号：",@"收文分类：",@"收文份数： ",@"密级：",@"备注"];
        CGFloat maxY = 0;
        for (NSInteger i = 0; i < names.count; i++) {
            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50)];
            view.backgroundColor = hexColor(ffffff);
            [scrollVIew addSubview:view];
            
            
            UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 30)];
            titlelabel.font = [UIFont systemFontOfSize:15];
            titlelabel.textColor = hexColor(333333);
            [view addSubview:titlelabel];
            titlelabel.text = names[i];
            
            UILabel *textFiled = [[UILabel alloc]initWithFrame:CGRectMake(10+80+20, 10, ScreenWidth-10-90-20, 30)];
            textFiled.textColor = hexColor(333333);
            textFiled.font = [UIFont systemFontOfSize:15];
            [view addSubview:textFiled];
            textFiled.tag = 100+i;
            textFiled.text = values[i];
            textFiled.numberOfLines = 0;
            CGSize size = [textFiled sizeThatFits:CGSizeMake(ScreenWidth-10-90-20, MAXFLOAT)];
            if (size.height>30) {
                CGRect frame = textFiled.frame;
                CGRect viewFrame = view.frame;
                viewFrame.size.height = viewFrame.size.height+(size.height-frame.size.height);
                  view.frame = viewFrame;
                frame.size.height = size.height;
                textFiled.frame = frame;
                CGRect titleFrame = titlelabel.frame;
                titleFrame.origin.y = (view.frame.size.height-30)/2.0;
                titlelabel.frame = titleFrame;
            }
            
            if (i == 5) {
                if ([values[i] isEqualToString:@"central"]) {
                    textFiled.text = @"中央文件";
                }else if ([values[i] isEqualToString:@"autonomousRegion"]){
                    textFiled.text = @"自治区文件";
                }else if ([values[i] isEqualToString:@"MuniGovernment"]){
                    textFiled.text = @"市委市政府文件";
                }else if ([values[i] isEqualToString:@"bureau"]){
                    textFiled.text = @"本局文件";
                }else if ([values[i] isEqualToString:@"MuniDepartments"]){
                    textFiled.text = @"市直相关部门文件";
                }
            }
            if (i == 1) {
                if ([ValidateUtils validateNull:values[i]].length > 10) {
               NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
               [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
               NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[values[i] substringToIndex:10] integerValue]];
               
               textFiled.text = [dateFormatter stringFromDate:date];
           }
            }
            if (i == 7) {
                if ([values[i] isEqualToString:@"0"]) {
                    textFiled.text = @"公开";
                }else if ([values[i] isEqualToString:@"1"]){
                    textFiled.text = @"国内";
                }else if ([values[i] isEqualToString:@"2"]){
                    textFiled.text = @"内部";
                }else if ([values[i] isEqualToString:@"3"]){
                    textFiled.text = @"秘密";
                }else if ([values[i] isEqualToString:@"4"]){
                    textFiled.text = @"机密";
                }else if ([values[i] isEqualToString:@"5"]){
                    textFiled.text = @"绝密";
                }
            }
            if (i == 8) {
                textFiled.numberOfLines = 0;
                CGSize size = [textFiled sizeThatFits:CGSizeMake(ScreenWidth-20, MAXFLOAT)];
                if (size.height > 30) {
                    textFiled.frame = CGRectMake(10, 10+30+10, ScreenWidth-20, size.height);
                    view.frame = CGRectMake(0, maxY, ScreenWidth, 10+size.height+10+10+30);
                }
                
            }
            UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, view.frame.size.height-1, ScreenWidth, 1)];
            lineViwe.backgroundColor = hexColor(f0f0f0);
            [view addSubview:lineViwe];
            
            maxY = CGRectGetMaxY(view.frame);
        }
        
        //,@"附件:"
        
        [self.filesArray  addObjectsFromArray:dict[@"attachment"]];
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, maxY, ScreenWidth, 50*(self.filesArray.count+1))];
        view.backgroundColor = hexColor(ffffff);
        [scrollVIew addSubview:view];
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        [view addSubview:titlelabel];
        titlelabel.text =@"附件：";
        if (self.filesArray.count > 0) {
            for (NSInteger i = 0; i < self.filesArray.count; i++) {
                NSDictionary *dict = self.filesArray[i];
                UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, CGRectGetMaxY(titlelabel.frame)+10 + i*50, ScreenWidth-10-10-40, 30)];
                label.font = [UIFont systemFontOfSize:14];
                label.textColor = hexColor(333333);
                label.text = dict[@"fileName"];
                [view addSubview:label];
                UIButton *downBtn = [UIButton buttonWithType:UIButtonTypeCustom];
                downBtn.frame = CGRectMake(ScreenWidth-50,CGRectGetMaxY(titlelabel.frame)+5 + i*50 , 40, 40);
                [downBtn setImage:[UIImage imageNamed:@"xiazai"] forState:UIControlStateNormal];
                [view addSubview:downBtn];
                downBtn.tag = 5000+i;
                [downBtn addTarget:self action:@selector(downFileStart:) forControlEvents:UIControlEventTouchUpInside];
                UIView *lineViwe = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(label.frame)+9, ScreenWidth, 1)];
                lineViwe.backgroundColor = hexColor(f0f0f0);
                [view addSubview:lineViwe];
            }
        }
        
        
        maxY = CGRectGetMaxY(view.frame);
        
        CGFloat buttonWidth = (ScreenWidth-40-30)/4.0;
        CGFloat buttonHeight = buttonWidth*42/122.0;
        
        if (!self.isFromMessageCenter) {
            UIView *bottomVIew = [[UIView alloc]initWithFrame:CGRectMake(0, maxY+10, ScreenWidth, 20+20+buttonHeight)];
            bottomVIew.backgroundColor = [UIColor whiteColor];
            [scrollVIew addSubview:bottomVIew];
            NSArray *buttonArray = @[@"cuiban-new",@"duban-new",@"guidang-new",@"lct-new"];
            for (NSInteger i = 0; i < buttonArray.count; i++) {
                UIImageView *imageViwe = [[UIImageView alloc]initWithFrame:CGRectMake(20+(buttonWidth+10)*i, 20, buttonWidth, buttonHeight)];
                imageViwe.image = [UIImage imageNamed:buttonArray[i]];
                [bottomVIew addSubview:imageViwe];
                imageViwe.userInteractionEnabled = YES;
                UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                btn.frame = CGRectMake(20+(buttonWidth+10)*i, 20, buttonWidth, buttonHeight);
                btn.tag = 300+i;
                [btn addTarget:self action:@selector(cuibanOrDuBanOrGuiDangOrLiuChengTuEvent:) forControlEvents:UIControlEventTouchUpInside];
                [bottomVIew addSubview:btn];
            }
            maxY = CGRectGetMaxY(bottomVIew.frame);
            scrollVIew.contentSize = CGSizeMake(0, maxY+10);
        } else {
            scrollVIew.contentSize = CGSizeMake(0, maxY+10);
        }
    }
}
#pragma mark 催办督办 归档 流程图
- (void)cuibanOrDuBanOrGuiDangOrLiuChengTuEvent:(UIButton*)button{
    switch (button.tag) {
        case 300:
        {
            //催办
            if ([self.dict[@"bpmStatus"] isEqualToString:@"1"]) {
                [MBProgressHUD showWarnMessage:@"公文未提交审批，无法进行此操作！"];
                return;
            }else if([self.dict[@"bpmStatus"] isEqualToString:@"3"]){
                [MBProgressHUD showWarnMessage:@"公文审批已完成，无法进行此操作！"];
                return;
            }else{
                ////1 催办。2督办
                [self getDuBanCuiBanData:1];
            }
        }
            break;
        case 301:
        {
            //督办
            
            if ([self.dict[@"bpmStatus"] isEqualToString:@"1"]) {
                [MBProgressHUD showWarnMessage:@"公文未提交审批，无法进行此操作！"];
                return;
            }else if([self.dict[@"bpmStatus"] isEqualToString:@"3"]){
                [MBProgressHUD showWarnMessage:@"公文审批已完成，无法进行此操作！"];
                return;
            }else{
                //1 催办。2督办
                [self getDuBanCuiBanData:2];
            }
            
        }
            break;
        case 302:
        {
            //归档
            if(![self.dict[@"bpmStatus"] isEqualToString:@"3"]){
                [MBProgressHUD showWarnMessage:@"公文未完成审批，不可归档！"];
                return;
            }else{
                if(![self.dict[@"archive"] isEqualToString:@"0"]){
                    NZKAlertView *tipView = [[NZKAlertView alloc] initWithImageView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gdcg"]] title:@"数据已归档，不可重复操作" delegate:nil buttonTitle:@"我知道了"];
                    [tipView show];
                    return;
                }else{
                    [self archiveData];
                }
                
            }
            
        }
            break;
        case 303:
        {
            //流程图
            if ([self.dict[@"bpmStatus"] isEqualToString:@"1"]) {
                [MBProgressHUD showWarnMessage:@"公文未提交审批，无法进行此操作！"];
                return;
            }else{
                LSLiuChengTuVC *lvc = [[LSLiuChengTuVC alloc]init];
                lvc.dict = self.dict;
                lvc.type = 2;
                [self.navigationController pushViewController:lvc animated:YES];
            }
        }
            break;
        default:
            break;
    }
}

- (UIView *)dbcbView{
    if (!_dbcbView) {
        _dbcbView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
        _dbcbView.backgroundColor =hexColorAlpha(000000, 0.5);
        _dbcbView.userInteractionEnabled = true;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dbcbViewTapped)];
        [_backgroundAlphaView addGestureRecognizer:tap];
    }
    
    return _dbcbView;
}
- (void)dbcbViewTapped{
    [self.dbcbView removeFromSuperview];
}
#pragma mark 点击催办或者督办时调用
- (void)getDuBanCuiBanData:(NSInteger)type{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"id"] = self.dict[@"id"];
    if (type == 1) {
        param[@"operFlag"] = @"A3";
    }else{
        param[@"operFlag"] = @"A4";
    }
    //1 催办。2督办
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",PressSuperviseManage,[UserInfoModel sharedInstance].token]  param:param completionHandler:^(id responseObject, NSError *connectionError) {
        hud.hidden = YES;
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            if (status.integerValue == 200) {
                self.dbcbDict = [NSDictionary dictionaryWithDictionary:[responseObject[@"data"]firstObject]];
                [self selectDuBanCuiBanBtn:type withDict:[responseObject[@"data"]firstObject]];
            }else{
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        }else{
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}
#pragma mark 归档
- (void)archiveData{
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",YbManageArchive,[UserInfoModel sharedInstance].token]  param:@{@"id":self.dict[@"id"]} completionHandler:^(id responseObject, NSError *connectionError) {
        hud.hidden = YES;
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            if (status.integerValue == 200) {
//                [MBProgressHUD showSuccessMessage:@"归档成功！"];
                NZKAlertView *tipView = [[NZKAlertView alloc] initWithImageView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gdcg"]] title:@"归档成功" delegate:nil buttonTitle:@"我知道了"];
                [tipView show];
            }else{
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        }else{
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}
- (void)selectDuBanCuiBanBtn:(NSInteger)type withDict:(NSDictionary*)dict{
    
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self.dbcbView];
    //1 催办。2督办
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, (ScreenHeight-(50+10+50+50+200+10))/2.0, ScreenWidth, 50+10+50+50+200+10)];
    view.backgroundColor = hexColor(ffffff);
    [self.dbcbView addSubview:view];
    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 50)];
    topView.backgroundColor = hexColor(EEEEEE);
    [view addSubview:topView];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth-20, 30)];
    label.textColor = hexColor(333333);
    if (type == 1) {
        label.text = @"催办";
    }else{
        label.text = @"督办";
    }
    [topView addSubview:label];
    CGFloat maxY = CGRectGetMaxY(topView.frame)+10;
    NSArray *names = @[@"接收人：",@"标题：",@"内容："];
    for (NSInteger i = 0; i < names.count; i++) {
        UILabel *titlelabel = [[UILabel alloc]initWithFrame:CGRectMake(0, maxY+10, 80, 30)];
        titlelabel.font = [UIFont systemFontOfSize:15];
        titlelabel.textColor = hexColor(333333);
        titlelabel.text = names[i];
        titlelabel.textAlignment = NSTextAlignmentRight;
        
        [view addSubview:titlelabel];
        
        if (i < 2) {
            UILabel *contentlabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(titlelabel.frame)+5, maxY+10, ScreenWidth-CGRectGetMaxX(titlelabel.frame)-10-5, 30)];
            contentlabel.textColor = hexColor(333333);
            contentlabel.font = [UIFont systemFontOfSize:15];
            if (i == 0) {
                contentlabel.text = [NSString stringWithFormat:@"  %@",[ValidateUtils validateNull:dict[@"receiveUserNames"]]];
            }else if (i == 1){
                contentlabel.text = [NSString stringWithFormat:@"  %@",[ValidateUtils validateNull:dict[@"fileTitle"]]];
            }
            [view addSubview:contentlabel];
            contentlabel.clipsToBounds = YES;
            contentlabel.layer.borderColor = hexColor(9F9F9F).CGColor;
            contentlabel.layer.borderWidth = 1;
            contentlabel.layer.cornerRadius = 5;
            maxY = CGRectGetMaxY(contentlabel.frame)+10;
        }else{
            UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(titlelabel.frame)+5, maxY+10, ScreenWidth-CGRectGetMaxX(titlelabel.frame)-10-5, 150)];
            [view addSubview:textView];
            textView.textColor = hexColor(333333);
            textView.font = [UIFont systemFontOfSize:15];
            textView.tag = 700;
            textView.clipsToBounds = YES;
            textView.layer.borderColor = hexColor(9F9F9F).CGColor;
            textView.layer.borderWidth = 1;
            textView.layer.cornerRadius = 5;
            maxY = CGRectGetMaxY(textView.frame)+10;
        }
        
    }
    UIButton *quxiaoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    quxiaoBtn.backgroundColor = topView.backgroundColor;
    quxiaoBtn.frame = CGRectMake(0, maxY, ScreenWidth/2.0-1, 50);
    [quxiaoBtn setTitle:@"取消" forState:UIControlStateNormal];
    [quxiaoBtn setTitleColor:hexColor(333333) forState:UIControlStateNormal];
    [view addSubview:quxiaoBtn];
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth/2.0-1, maxY, 1, 50)];
    lineView.backgroundColor = hexColor(666666);
    [view addSubview:lineView];
    
    UIButton *okBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    okBtn.backgroundColor = topView.backgroundColor;
    okBtn.frame = CGRectMake(ScreenWidth/2.0, maxY, ScreenWidth/2.0, 50);
    [okBtn setTitle:@"确定" forState:UIControlStateNormal];
    [okBtn setTitleColor:hexColor(333333) forState:UIControlStateNormal];
    [view addSubview:okBtn];
    
    [quxiaoBtn addTarget:self action:@selector(dbcbViewTapped) forControlEvents:UIControlEventTouchUpInside];
    if (type == 1) {
        [okBtn addTarget:self action:@selector(cuibanHttpRequest) forControlEvents:UIControlEventTouchUpInside];
    }else{
        [okBtn addTarget:self action:@selector(dubanHttpRequest) forControlEvents:UIControlEventTouchUpInside];
    }
}
- (void)cuibanHttpRequest{
    [self.dbcbView endEditing:YES];
    UITextView *textView = [self.dbcbView viewWithTag:700];
    if (textView.text.length == 0) {
        [MBProgressHUD showWarnMessage:@"请填写内容！"];
        return;
    }
    NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:self.dbcbDict];
    param[@"operFlag"] = @"A3";
    param[@"remindType"] = @"1";
    param[@"content"] = textView.text;
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",PressSuperviseConfirm,[UserInfoModel sharedInstance].token]  param:param completionHandler:^(id responseObject, NSError *connectionError) {
        hud.hidden = YES;
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            if (status.integerValue == 200) {
                [MBProgressHUD showSuccessMessage:@"信息发送成功！"];
                [self.dbcbView removeFromSuperview];
            }else{
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        }else{
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}
- (void)dubanHttpRequest{
    [self.dbcbView endEditing:YES];
    UITextView *text = [self.dbcbView viewWithTag:700];
    if (text.text.length == 0) {
        [MBProgressHUD showWarnMessage:@"请填写内容！"];
        return;
    }
    NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:self.dbcbDict];
    param[@"operFlag"] = @"A4";
    param[@"remindType"] = @"1";
    param[@"content"] = text.text;
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [NetworkUtils requestNOHandleWithMethod:@"POST" URL:[NSString stringWithFormat:@"%@&token=%@",PressSuperviseConfirm,[UserInfoModel sharedInstance].token]  param:param completionHandler:^(id responseObject, NSError *connectionError) {
        hud.hidden = YES;
        if (!connectionError) {
            NSNumber *status = [responseObject objectForKey:@"status"];
            if (status.integerValue == 200) {
                [MBProgressHUD showSuccessMessage:@"信息发送成功！"];
                [self.dbcbView removeFromSuperview];
            }else{
                [MBProgressHUD showTipMessageInWindow:responseObject[@"message"]];
            }
        }else{
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
    
}
- (void)downFileStart:(UIButton*)button{
    //(NSString*)fileStr withFileName:(NSString*)fileName
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    if (self.type == 1) {
        
        [dict addEntriesFromDictionary:self.filesArray[button.tag-5000]];
    }else{
        [dict addEntriesFromDictionary:self.upLoadFileArray[button.tag-5000]];
    }
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths lastObject];
    NSString *docPath = [ValidateUtils validateNull:dict[@"fileName"]];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    [NetworkUtils downloadFileWithURL:dict[@"filePath2"] filePath:[NSString stringWithFormat:@"%@/%@",documentsDirectory,docPath] progress:^(NSProgress *downloadProgress) {
        
    } completionHandler:^(id responseObject, NSError *connectionError) {
        hud.hidden = YES;
        if (!connectionError) {
            
            UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"系统提示" message:@"下载完成，是否查看？" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *queding = [UIAlertAction actionWithTitle:@"查看" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                LSDownloadFilesViewController *lvc = [[LSDownloadFilesViewController alloc]init];
                [self.navigationController pushViewController:lvc animated:YES];
            }];
            UIAlertAction *quxiao = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                
            }];
            [alert addAction:quxiao];
            [alert addAction:queding];
            [self presentViewController:alert animated:YES completion:nil];
            
        } else {
            [MBProgressHUD showTipMessageInWindow:connectionError.localizedDescription];
        }
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
